<template>
    <div class="box">
      <Head></Head>
         
          <main>
             <Left></Left>
            
            <div>
                <h1 style="margin:5px 0;">{{shopList.name}}</h1>
            <img style="width:150px;border-radius:5px" :src="img" alt="">
            <p style="color:gray">地址：{{shopList.address}}</p>
            <p>{{shopList.jshao}}</p> 
            <p style="color:green">联系方式：{{shopList.phone}}</p>
            <p style="color:orange">营业时间:{{shopList.start_time}}-{{shopList.end_time}}</p>
            <p style="color:green">配送费：<span style="color:red">￥{{shopList.pei_money}}</span></p>
            <p style="color:green">起送费：<span style="color:red">￥{{shopList.qi_money}}</span></p>
          
             <button @click="handleEdit(shopList)">编辑</button>
            </div>
            <Right></Right>
          </main>
            <section  v-show="bool" @click="bian">
                  <div class="bian">
                       <el-form  ref="form" :hide-required-asterisk="bool" :model="form" label-width="80px">
                      <el-form-item :required="bool" label="店铺名称">
                        <el-input v-model="form.name"></el-input>
                      </el-form-item>
                      
                      <el-form-item :required="bool" label="详细地址">
                        <el-input v-model="form.address" placeholder="请输入地址"></el-input>
                      </el-form-item>
                      <el-form-item :required="bool" label="联系电话">
                        <el-input v-model="form.phone" placeholder="请输入手机号"></el-input>
                      </el-form-item>
                      <el-form-item label="店铺简介">
                        <el-input v-model="form.jieshao" placeholder="请输入店铺简绍"></el-input>
                      </el-form-item>
                      
                     <el-form-item label="店铺特点">
                  <el-checkbox-group v-model="form.type">
                    <el-checkbox label="品牌保证" name="type"></el-checkbox>
                    <el-checkbox label="蜂鸟专送" name="type"></el-checkbox>
                    <el-checkbox label="新开店铺" name="type"></el-checkbox>
                    <el-checkbox label="外卖保" name="type"></el-checkbox>
                    <el-checkbox label="准时达" name="type"></el-checkbox>
                      <el-checkbox label="开发票" name="type"></el-checkbox>
                  </el-checkbox-group>
                </el-form-item>
                  <el-form-item label="配送费">
                  <el-input-number v-model="form.peinum" controls-position="right" @change="handleChange" :min="1" :max="10"></el-input-number>
                </el-form-item>     
                  <el-form-item label="起送费">
                  <el-input-number v-model="form.qinum" controls-position="right" @change="handleChange1" :min="1" :max="20"></el-input-number>
                </el-form-item>     
                      
                      
                  
                      <el-form-item label="店铺头像">
                      <el-upload
                      class="avatar-uploader"
                      action="/myE/addShop/add_img"
                      list-type="picture-card"
                      :show-file-list="false"
                      :on-success="handleAvatarSuccess"
                      :before-upload="beforeAvatarUpload">
                      <img v-if="imageUrl" :src="imageUrl" class="avatar">
                      <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                    </el-upload>

                      </el-form-item>

                      <el-form-item label="营业执照">
                                    <el-upload
                                    class="avatar-uploader"
                                    action="/myE/addShop/add_img"
                                    list-type="picture-card"
                                    :show-file-list="false"
                                    :on-success="handleAvatarSuccess1"
                                    :before-upload="beforeAvatarUpload1">
                                    <img v-if="imageUrl1" :src="imageUrl1" class="avatar">
                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                  </el-upload>

                      </el-form-item>

                      <el-form-item>
                        <el-button type="primary" @click="onSubmit">立即创建</el-button>
                        <el-button @click="qu">取消</el-button>
                      </el-form-item>
                    </el-form>  
                  </div>
            </section>
            <!-- <div class="ping">
                <video src="../assets/夜夜夜漫长.mp4" autoplay></video>
            </div> -->
            <div class="ping">
               <ul>
          <li v-for="item,i in ping" :key="i">
              <div class="top">
                  <img style="width:5vw;height:5vw" :src="$image+item.user_img" alt="">
                  <dl>
                      <p style="font-size:22px;margin-left:1vw;text-align:left">{{item.username}}</p>
                      <div style="display:flex;">
                         <p style="font-size:15px;color:gray;margin:2vw 1vw 0 1vw;">服务</p>
                         <p style="font-size:15px;margin:2vw .8vw 0 .8vw;color:#333">超赞</p>
                          <p style="font-size:15px;color:gray;margin:2vw 1vw 0 1vw;">味道</p>
                         <p style="font-size:15px;margin:2vw .8vw 0 .8vw;color:#333">超赞</p>
                          <p style="font-size:15px;color:gray;margin:2vw 1vw 0 1vw;">包装</p>
                         <p style="font-size:15px;margin:2vw .8vw 0 .8vw;color:#333">超赞</p>
                          <p style="font-size:15px;color:gray;margin:2vw 1vw 0 1vw;">配送</p>
                         <p style="font-size:15px;margin:2vw .8vw 0 .8vw;color:#333">超赞</p>
                      </div>
                  </dl>
                  <p style="font-size:16px;color:gray;margin-left:18vw">{{item.ping_time}}</p>
              </div>
              <p style="text-align:left">{{item.content}}</p>
              <div class="zhao">
                 
                  <img v-for="items,index in item.ping_img" :key="index"  :src="$images+items" alt="">
              </div>
              <div class="hui" style="margin:1vw 0;">
                  <p style="">商家回复</p>
                  <dl>
                     
                      感谢您选择品尝本店的美食，谢谢您认可我们的口味和服务，我们会继续努力，为您提供更好的服务，祝您生活愉快！
                  </dl>
              </div>
          </li>
      </ul>
            </div>
           <aside v-show="ding" @click="scrollTo">
             <i class="iconfont" style="font-size:20px">&#xe614;</i>
            
           </aside>
    </div>
</template>

<script>
import {ajax_shopList,ajax_addShop,ajax_getPing} from '../ajax/index'
import Head from '../components/head'
import Left from '../components/leftDong'
import Right from '../components/right'
export default {
    name: '',
    data(){
        return{
           shopList:[], 
          
           lastYe:1,
           bool:false,
           
           form: {
            name: '',
            address:'',
            phone:'',
            
            jieshao:'',
            type: [],
            peinum:'',
            qinum:'',
            region: '',
         
          dialogImageUrl: '',
        dialogVisible: false,
        disabled: false,
        
        },
        imageUrl: '',
        imageUrl1:'',
        img_url:'',
        img_url1:'',
        img:``,
        ping:[],
        ding:false,
       
  
        }
    },
    inject:['reload'],
    methods:{
        handleEdit(row) {
        // console.log(index, row);
        this.Id=row.Id;
        this.bool=true;
        this.form.name=row.name;
        this.form.address=row.address;
        this.form.phone=row.phone;
        this.form.peinum=row.pei_money;
        this.form.qinum=row.qi_money
        this.form.jieshao=row.jshao;
       
        this.imageUrl=`http://127.0.0.1:8888/imgs/shop/${row.shop_img}`
        this.imageUrl1=`http://127.0.0.1:8888/imgs/shop/${row.yingY_img}`
      },
      
   
        bian(e){
              // console.log(e.target)
             if(e.target.tagName=="SECTION"){
              //  console.log("fei")
               this.bool=false
               console.log(this.bool)
             }
        },
        qu(){
            this.bool=false
        },
        onSubmit(){
          // console.log(this.value)
               ajax_addShop({
                    Id:this.Id,
                    name:this.form.name,
                    address:this.form.address,
                    phone:this.form.phone,
                    jshao:this.form.jieshao,
                      tedian:JSON.stringify(this.form.type),
                     pei_money:this.form.peinum,
                qisong_money:this.form.qinum,
                    shop_img:this.img_url, 
                    yingY_img:this.img_url1,
           
         }).then(res=>{
           alert(res.message)
            this.reload()
         })
        },
         handleAvatarSuccess(res, file) {
        this.imageUrl = URL.createObjectURL(file.raw);
        this.img_url=file.name
        console.log(file)
        // this.$refs.upload.clearFiles()
        
      },
       handleAvatarSuccess1(res, file) {
        this.imageUrl1 = URL.createObjectURL(file.raw);
        this.img_url1=file.name
        console.log(file)
        // this.$refs.upload.clearFiles()
        
      },
      beforeAvatarUpload(file) {
        const isJPG = file.type === 'image/jpeg';
        const isLt2M = file.size / 1024 / 1024 < 2;

        if (!isJPG) {
          this.$message.error('上传头像图片只能是 JPG 格式!');
        }
        if (!isLt2M) {
          this.$message.error('上传头像图片大小不能超过 2MB!');
        }
        return isJPG && isLt2M;
      },
       beforeAvatarUpload1(file) {
        const isJPG = file.type === 'image/jpeg';
        const isLt2M = file.size / 1024 / 1024 < 2;

        if (!isJPG) {
          this.$message.error('上传头像图片只能是 JPG 格式!');
        }
        if (!isLt2M) {
          this.$message.error('上传头像图片大小不能超过 2MB!');
        }
        return isJPG && isLt2M;
      },
       handleChange(value) {
        console.log(value);
      },
      handleChange1(value) {
        console.log(value);
      },
      scrollTops(){
        var scrollTop=document.documentElement.scrollTop||document.body.scrollTop;
        console.log(scrollTop);
        if(scrollTop>1000){
          this.ding=true;
        }else{
          this.ding=false;
        }
      },
      scrollTo(){
        window.scrollTo(0,0);
      }
    },
    created(){
        ajax_shopList().then(data=>{
           
            this.shopList=data.shopList[0];
            //  console.log(this.shopList);
            this.img=`http://127.0.0.1:8888/imgs/shop/${this.shopList.shop_img}`
        }),
        ajax_getPing({}).then(res=>{
           res.data1.forEach((item,i,array) => {
                    item.ping_img=item.ping_img.substring(0,item.ping_img.length-1)
                    item.ping_img=item.ping_img.slice(1);
                    item.ping_img=item.ping_img.replace(/\"/g, "")
                    
                item.ping_img=item.ping_img.split(',');
                
               
              });
            //   console.log(res.data1)
              this.ping=res.data1;
        })

    },
    mounted(){
        window.addEventListener('scroll',this.scrollTops)
    },
    destroyed(){
        window.removeEventListener('scroll',this.scrollTops)
    },
 
    components:{
        Head,
        Left,
        Right,
    }
}
</script>

<style scoped>
aside{
  position: fixed;
  bottom:5vw;
  right: 5vw;
  width: 3vw;
  height: 3vw;
  text-align: center;
  line-height: 3vw;
  background-color: white;
  box-shadow: 0 0 5px 1px #999    ;
  border-radius: 5px;
}
.ping{
  width: 76vw;
  margin:10vh auto;
  padding:2vw;
  /* height: 30px; */
  /* background-color: orange; */
}
 .demo-table-expand {
    font-size: 0;
  }
  .demo-table-expand label {
    width: 90px;
    color: #99a9bf;
  }
  .demo-table-expand .el-form-item {
    margin-right: 0;
    margin-bottom: 0;
    width: 50%;
  }

.box >>> th{
    background-color: #eef1f6;
    color: black;
}
.box >>> button:nth-of-type(3){
  background-color: red;
  color: white;
}
td{
    cursor: pointer;
}
main{
  width: 90%;
  display: flex;
  justify-content: space-around;
  align-items: center;
  margin: 20px auto;
  border: 1px solid rgb(211, 208, 208);
}
main p{
  margin: 5px 0;
}
main button{
  border: 0;
  outline: 0;
  width: 100px;
  padding: 5px 2px;
  background-color: red;
  background-image: linear-gradient(to top right,rgb(195, 0, 255),rgb(255, 238, 0));
  border-radius: 5px;
  color: white;
  margin: 10px 0;
  cursor: pointer;
}
table{
    width:100%;
    border: 1px solid gray;
    border-collapse: collapse;
    margin: 15px 0;
}
table tr{
    border: gray !important;
   
}
tr td:nth-child(n+2){
    width: 23.6%;
}
.head{
    background-color: #eef1f6;
    
}
.head td{
   padding: 8px 0;
   font-weight: 700;
}
td{
    text-align: left;
}
.content{
    position: relative;
}
.content:hover{
    background-color: rgb(250, 250, 250);
}
.content td{
    height: 50px;
    line-height: 50px;
    /* text-align: left; */
    border-top: 1px solid #ebeff3;
}
td button{
    border: none;
    outline: none;
    padding: 2px 5px;
    border-radius: 6px;
    margin: 0 5px;
    border: 1px solid gainsboro;
    background-color: white;
}
.jian{
    width: 50px;
    padding: 0 12px;
    /* position: absolute; */
    /* margin-left: 30px; */
    /* margin-right: 30px; */
}
.fenye{
    display: flex;
   margin: 15px auto;

}
.fenye p{
 padding: 2px 3px;
    margin:0 5px;
    border: 1px solid gray;
}
.fenye ul{
    display: flex;
}
.fenye li{
    padding: 5px 8px;
    border: 1px solid gray;
    margin: 0 2px;
}
section{
  width: 100%;
  height: 100vh;
  position:fixed;
  top: 0;
  left:0;
  background-color: rgba(48, 37, 37, 0.192);
}

section>.bian{
  width: 50%;
  height: 600px;
  background-color: white;
  overflow: auto;
  position: absolute;
  top:0;
  left:0;
  right:0;
  bottom:0;
  margin: auto;
  padding: 20px;
  border-radius: 3px;
   scrollbar-width:none;
  /* margin-left: 100px; */
}
/* section>.bian::-moz-scrollbar{
  scrollbar-width:none;
} */
section >>> img{
  width: 100%;
  height: 100%;
}
ul{
    /* width: 100vw; */

}
ul>li{
    width: 72vw;
    padding: 4vw;
    padding-top: 0;
}
li>.top{
  display: flex;
  align-items: center;
}
li>p{
    margin-top: 1.5vw;
    width: 70vw;
     font-family: "楷体";
}
dl>p{
    font-family: "楷体";
    /* font-weight: 500; */
    font-weight: bold;
    margin-left: 1vw;
}
.hui{
    width: 75%;
    margin: 0 auto;
    padding:2vw;
    background-color: #eee;
    border-radius: 5px;

}
.hui>p{
    font-size: 13px;
    font-weight:bold;
    font-family: '宋体';
}
.hui>dl{
    font-size: 12px;
    margin: 1vw auto;
}
.zhao{
   width:74vw;
    margin: 1vw 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    
}
.zhao>img{
    /* width: 30%; */
    width: calc((100% - 4vw)/5);
    height: 200px;
    border-radius: 5px;
    margin-right: 2vw;
}
</style>